//
//  ViewController.m
//  01-上下文动画
//
//  Created by 大欢 on 16/6/15.
//  Copyright © 2016年 大欢. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIView *testView;
@property (weak, nonatomic) IBOutlet UIImageView *qqView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    


    
}
- (IBAction)startAnimation:(id)sender {
    
    //创建动画
    [UIView beginAnimations:@"qq" context:nil];
    //设置动画时间
    [UIView setAnimationDuration:5];
    //设置动画延时
    [UIView setAnimationDelay:0];
    
    /*
     typedef NS_ENUM(NSInteger, UIViewAnimationCurve) {
     UIViewAnimationCurveEaseInOut,         // 先快后慢
     UIViewAnimationCurveEaseIn,            // 一直快
     UIViewAnimationCurveEaseOut,           // 一直慢
     UIViewAnimationCurveLinear             // 匀速
     };
     
     
     */
    //设置动画快慢
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    //设置重复次数
    [UIView setAnimationRepeatCount:1];
    //设置代理对象
    [UIView setAnimationDelegate:self];
    //将要开始
    [UIView setAnimationWillStartSelector:@selector(willStartAction:)];
    //已经结束
    [UIView setAnimationDidStopSelector:@selector(didStopAction:)];
    
    //设置反转动画
//    [UIView setAnimationRepeatAutoreverses:YES];
    
    /***********设置结束状态**********/
    
    //frame,center,bounds,alpha,color
//    self.qqView.center = CGPointMake(300, 300);
//    self.qqView.frame = CGRectMake(300, 300, 50, 50);
//    self.qqView.alpha = 0.5;
//    self.testView.backgroundColor = [UIColor redColor];
    
    
    //拉伸Scale
    //参数是width,height的倍数
//    self.qqView.transform = CGAffineTransformMakeScale(1.5, 1.5);
//    self.qqView.transform = CGAffineTransformScale(self.qqView.transform, 1.1, 1.1);
    
    //旋转
//    self.qqView.transform = CGAffineTransformMakeRotation(M_PI _4);
//    self.qqView.transform = CGAffineTransformRotate(self.qqView.transform, M_PI_4);
    
    //平移
//    self.qqView.transform = CGAffineTransformMakeTranslation(200, 400);
//    self.qqView.transform = CGAffineTransformTranslate(self.qqView.transform, 50, 50);
    
    //提交动画
    [UIView commitAnimations];
}

- (void)willStartAction:(NSString *)animationID {
    
    NSLog(@"%@",animationID);
    NSLog(@"动画开始");
}

- (void)didStopAction:(id)sender {
    
    NSLog(@"动画结束");
}

@end
